﻿<%@ Page Title="" Language="C#" MasterPageFile="~/CmsSystem/MasterPage/AdminForm.Master"
    AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Cms.Web.CmsSystem.SysAdmin.FormSetting.Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="/Scripts/jqGrid/lan/grid.locale-cn.js" type="text/javascript"></script>
    <script src="/Scripts/jqGrid/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/Scripts/customgrideditor.js"></script>
    <link href="/App_Themes/Default/jqueryui/jquery-ui-1.7.1.custom.css" rel="stylesheet"
        type="text/css" />
    <link href="/App_Themes/Default/ui.jqgrid.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/easyui/easyloader.js" type="text/javascript"></script>
    <script type="text/javascript">
        FormID = "formsetting";
        var setting = 
        {
            width:605,
            colNames: ['ID', '名称', '表名', '视图名', '主键字段', '序号字段', '主表关联字段', '与主表关联字段', '表单编号'],
            colModel: [
                     { name: 'Id', index: 'Id', width: 80, key: true, hidden: true },
                     { name: 'Caption', index: 'Caption', width: 120, editable: true },
                     { name: 'Tablename', index: 'Tablename', width: 150, editable: true },
                     { name: 'Viewname', index: 'Viewname', width: 80, editable: true },
                     { name: 'Keyfield', index: 'Keyfield', width: 80, editable: true },
                     { name: 'Idfield', index: 'Idfield', width: 80, editable: true },
                     { name: 'Masterfield', index: 'Masterfield', width: 80, editable: true },
                     { name: 'Detailfield', index: 'Detailfield', width: 80, editable: true },
                     { name: 'Formid', index: 'Formid', width: 50, hidden: true }
                    ]
        };
        function GetColumns(TableName, callback) {
            var url = "/tools/JSON.ashx?param=db&type=info&act=getcolumns&TableName=" + TableName;
            $.ajax({
                url: url,
                dataType: "json",
                success: function (data) {
                    callback(data);
                }
            });
        }
        $(function () {
            var assign = {};
            assign["Formid"] = ID;
            FormLoadCallBack = function () {
                using("combobox", function () {
                    var width = $("[name=TABLENAME]").width();
                    $("select").not("[name=TABLENAME],[name=DATATYPE],[name=PARENTIDFIELD]").each(function () {
                        $(this).combobox({
                            width: $(this).width(),
                            valueField: '0',
                            textField: '1',
                            eidtable: false,
                            onShowPanel: function (e, f, g) {
                                var combobj = $(this);
                                GetColumns($("[comboname=TABLENAME]").combobox("getValue"), function (data) {
                                    combobj.combobox("loadData", data);
                                });
                            }
                        });
                    });
                    $("[name=TABLENAME]").combobox({
                        width: width,
                        valueField: '0',
                        textField: '1',
                        editable: false,
                        url: "/tools/JSON.ashx?param=db&type=info&act=getalltable",
                        onChange: function (newValue, oldValue) {
                            GetColumns(newValue, function (data) {
                                $("select").not("[comboname=TABLENAME]").each(function () {
                                    $(this).combobox("loadData", data);
                                });
                            });
                        }
                    });
                });
            }
            gridLoad("DETAIL", setting, assign);
        });
    
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
        <fieldset style="float: left;">
            <legend>主界面</legend>
            <div class="row">
                <label class="label">
                    标题</label>
                <label class="input">
                    <input type="text" name="CAPTION" class="XI" /></label>
            </div>
            <div class="row">
                <label class="label">
                    对应表名</label>
                <label class="input">
                    <select name="TABLENAME" class="I">
                    </select>
                </label>
                <label class="label">
                    对应视图名</label>
                <label class="input">
                    <input type="text" name="VIEWNAME" class="I" /></label>
            </div>
            <div class="row">
                <label class="label">
                    主键字段</label>
                <label class="input">
                    <select name="KEYFIELD" id="KEYFIELD" class="I">
                    </select></label>
                <label class="label">
                    编号字段</label>
                <label class="input">
                    <select name="IDFIELD" id="IDFIELD" class="I">
                    </select></label>
            </div>
            <div class="row">
                <label class="label">
                    创建人编号字段</label>
                <label class="input">
                    <select name="CREATEUSERFIELD" id="CREATEUSERFIELD" class="I">
                    </select></label>
                <label class="label">
                    创建人名称字段</label>
                <label class="input">
                    <select name="CREATEUSERNAMEFIELD" id="CREATEUSERNAMEFIELD" class="I" ></select></label>
            </div>
            <div class="row">
                <label class="label">
                    创建日期字段</label>
                <label class="input">
                    <select name="CREATEDATEFIELD" id="CREATEDATEFIELD" class="I">
                    </select></label>
                <label class="label">
                    记录类型</label>
                <label class="input">
                    <input type="text" name="RECTYPE" class="I" /></label>
            </div>
            <div class="row">
                <label class="label">
                    标题字段</label>
                <label class="input">
                    <select name="TITLEFIELD" id="TITLEFIELD" class="I">
                    </select></label>
                <label class="label">
                    数据存储类型</label>
                <label class="input">
                    <select name="DATATYPE" class="I">
                        <option value="OBJ">面向对象</option>
                        <option value="DB">数据库</option>
                    </select>
                </label>
            </div>
            <div class="row">
                <label class="label">
                    对应类</label>
                <label class="input">
                    <input type="text" name="CLASSNAME" class="I" /></label>
            </div>
        </fieldset>
        <fieldset style="float: left;">
            <legend>高级</legend>
            <div class="mrow">
                <label class="label">
                    查询SQL</label>
                <label class="input">
                    <textarea name="SQL"></textarea>
                </label>
            </div>
            <div class="row">
                <label class="label">
                    父节点字段</label>
                <label class="input">
                    <select name="PARENTIDFIELD" style="width: 200px">
                    </select>
                </label>
            </div>
        </fieldset>
        <b style="clear: both;"></b>
    </div>
    <div style="clear: both;">
        <fieldset>
            <legend>子表信息</legend>
            <div id="gridpagerDETAIL">
            </div>
            <table id="DETAIL" name="DETAIL">
            </table>
        </fieldset>
    </div>
</asp:Content>
